package org.starapp.rbac.entity;

import javax.persistence.GenerationType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author wangqiang@cisoft.com.cn
 *
 */
@Entity
@Table(name = "rbac_objects")
public class Objects implements Serializable{
		
				
		/**
		 * OBJECT_ID
		 */
		private String objectId;
				
		/**
		 * OBJECT_NAME
		 */
		private String objectName;
		
		/**
		 * Objects
		 */
		private Objects objects;
		


		private List<Operations> operationsM2MList;				

		private List<Permissons> permissonsList;				

		
				
		@Id
		@Column(name="OBJECT_ID")
		@NotBlank
		public String getObjectId(){
			return this.objectId;
		}
		
		public void setObjectId(String objectId){
			this.objectId = objectId;
		}
		
				
		@NotBlank
		public String getObjectName(){
			return this.objectName;
		}
		
		public void setObjectName(String objectName){
			this.objectName = objectName;
		}
		
		
				
		@ManyToMany
		@JoinTable(name = "rbac_objects_operations", joinColumns={@JoinColumn(name="OBJECT_ID") },inverseJoinColumns={@JoinColumn(name="OPERATION_ID")})		
		public List<Operations> getOperationsM2MList(){
			return this.operationsM2MList;
		}
		
		public void setOperationsM2MList(List<Operations> operationsM2MList){
			this.operationsM2MList = operationsM2MList;
		}
				
		@OneToMany(mappedBy = "objects")
		public List<Permissons> getPermissonsList(){
			return this.permissonsList;
		}
		
		public void setPermissonsList(List<Permissons> permissonsList){
			this.permissonsList = permissonsList;
		}

		@OneToOne
		@JoinColumn(name = "PARENT_OBJECT_ID")					
		public Objects getObjects(){
			return this.objects;
		}
		
		public void setObjects(Objects objects){
			this.objects = objects;
		}

		
		@Override
		public String toString() {
			return ToStringBuilder.reflectionToString(this);
		}
	
	}

